package com.code9xs.util;

import java.util.UUID;

public class IDPoolUtil {
    private static SnowflakeIdWorker snowflake = new SnowflakeIdWorker(0,0);

    /**
     * 采取雪花算法获取8位用户id
     * @return
     */
    public static Integer getUID(){
        Long id = snowflake.nextId() % 100000000;
        return id.intValue();
    }
    /**
     * 采取雪花算法获取6位社团id
     * @return
     */
    public static Integer getAID(){
        Long id = snowflake.nextId() % 1000000;
        return id.intValue();
    }

    /**
     * 采取雪花算法获取9-10位其他id
     * @return
     */
    public static Integer getOtherID(){
        Long id = snowflake.nextId();
        return id.intValue() > 0 ? id.intValue() : -id.intValue();

    }

    public static String get16UUID(){
        String randomUUID = UUID.randomUUID().toString().replaceAll("-", "");
        String substring = randomUUID.substring(randomUUID.length()-16, randomUUID.length());
        return substring;
    }

    public static String get32UUID() {
        String randomUUID = UUID.randomUUID().toString().replace("-", "");
        return randomUUID;
    }
}
